package com.buss.purchase.model;

import com.buss.base.model.Branch;
import com.buss.core.dic.CheckStatus;
import com.buss.customer.model.Customer;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 采购订单主表
 * Created with IntelliJ IDEA.
 * User: gykl
 * Date: 12-5-22
 * Time: 上午11:28
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "purchase_ordermaster")
@TableGenerator(name="pcOrderMaster_pk_sequence",initialValue=1,allocationSize=1,pkColumnName="seq_col",
pkColumnValue="ordermaster_seq",valueColumnName="seq_val",table="purchase_pk_sequence")
public class PurchaseOrderMaster implements Serializable {

	private static final long serialVersionUID = 7525929120030627056L;

	/**表主键*/
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE,generator = "pcOrderMaster_pk_sequence")
    private Long id;

	/**供应商信息*/
	@ManyToOne(cascade=CascadeType.REFRESH,fetch=FetchType.EAGER)
	@JoinColumn(name="supplierId",nullable=false)
	private Customer supplier;
	
	/**库房信息*/
	@ManyToOne(cascade=CascadeType.REFRESH,optional=true)
	@JoinColumn(name="branchId",nullable=false)
	private Branch branch;
	
    /**销售人员编码*/
	@Column(nullable=false)
    private Long salesManId;
    
    /**销售人员名称*/
	@Column(nullable=false,length = 50)
    private String salesManName;

    /**订单号*/
	@Column(nullable = false,length = 20)
    private String orderNumber;

    /**订单时间*/
	@Temporal(value = TemporalType.DATE)
    private Date orderDate;
    
	/**预计到达时间*/
	@Temporal(value = TemporalType.DATE)
	private Date predictArriveDate;
	
    /**合计金额*/
	@Column(nullable = false,precision = 8,scale = 2)
    private Float amount;
    
    /**折让额*/
	@Column(nullable = false,precision = 8,scale = 2)
    private Float allowance;
    
    /**备注*/
	@Column(length = 254)
    private String intro;
    
    /**审核状态*/
	@Column(updatable=false)
	@Enumerated(value = EnumType.STRING)
    private CheckStatus checkStatus;
    
	/**审核说明*/
	@Column(length=254,updatable=false)
	private String checkIntro;
	
    /**审核人编码*/
	@Column(updatable=false)
    private Long checkUserId;
    
    /**审核人姓名*/
	@Column(length = 50,updatable=false)
    private String checkUserName;
    
    /**审核时间*/
	@Column(updatable=false)
	@Temporal(value = TemporalType.TIMESTAMP)
    private Date checkDate;
    
	/**是否到达*/
	@Column(updatable=false,length=20)
	@Enumerated(EnumType.STRING)
	private ArriveStatus isArrive;
	
	/**到货时间*/
	@Column(updatable=false)
	@Temporal(value = TemporalType.DATE)
	private Date arriveDate;
	
    /**录入人员ID*/
	@Column(updatable=false)
    private Long createUserId;

    /**录入人员姓名*/
	@Column(nullable = false,length = 50,updatable=false)
    private String createUserName;
    
    /**录入时间*/
	@Column(updatable=false)
	@Temporal(value = TemporalType.TIMESTAMP)
    private Date createDate;

	/**采购订单明细信息*/
	@Transient
	private List<PurchaseOrderDetail> details;
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Branch getBranch() {
		return branch;
	}

	public void setBranch(Branch branch) {
		this.branch = branch;
	}

	public Long getSalesManId() {
		return salesManId;
	}

	public void setSalesManId(Long salesManId) {
		this.salesManId = salesManId;
	}

	public String getSalesManName() {
		return salesManName;
	}

	public void setSalesManName(String salesManName) {
		this.salesManName = salesManName;
	}

	public String getOrderNumber() {
		return orderNumber;
	}

	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}

	public Float getAllowance() {
		return allowance;
	}

	public void setAllowance(Float allowance) {
		this.allowance = allowance;
	}

	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}

	public CheckStatus getCheckStatus() {
		return checkStatus;
	}

	public void setCheckStatus(CheckStatus checkStatus) {
		this.checkStatus = checkStatus;
	}

	public String getCheckIntro() {
		return checkIntro;
	}

	public void setCheckIntro(String checkIntro) {
		this.checkIntro = checkIntro;
	}

	public Long getCheckUserId() {
		return checkUserId;
	}

	public void setCheckUserId(Long checkUserId) {
		this.checkUserId = checkUserId;
	}

	public String getCheckUserName() {
		return checkUserName;
	}

	public void setCheckUserName(String checkUserName) {
		this.checkUserName = checkUserName;
	}

	public Date getCheckDate() {
		return checkDate;
	}

	public void setCheckDate(Date checkDate) {
		this.checkDate = checkDate;
	}

	public Long getCreateUserId() {
		return createUserId;
	}

	public void setCreateUserId(Long createUserId) {
		this.createUserId = createUserId;
	}

	public String getCreateUserName() {
		return createUserName;
	}

	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public List<PurchaseOrderDetail> getDetails() {
		return details;
	}

	public void setDetails(List<PurchaseOrderDetail> details) {
		this.details = details;
	}

	public Date getPredictArriveDate() {
		return predictArriveDate;
	}

	public void setPredictArriveDate(Date predictArriveDate) {
		this.predictArriveDate = predictArriveDate;
	}

	public ArriveStatus getIsArrive() {
		return isArrive;
	}

	public void setIsArrive(ArriveStatus isArrive) {
		this.isArrive = isArrive;
	}

	public Date getArriveDate() {
		return arriveDate;
	}

	public void setArriveDate(Date arriveDate) {
		this.arriveDate = arriveDate;
	}

	public Customer getSupplier() {
		return supplier;
	}

	public void setSupplier(Customer supplier) {
		this.supplier = supplier;
	}
	
	public enum ArriveStatus{
		allArrive("全部到货"),
		partArrive("部分到货"),
		notArrive("未到货");
		private String value;
		ArriveStatus(String value){
			this.value = value;
		}
		public String getValue(){
			return value;
		}
		
	}
}
